#!/bin/bash

ve-php-run(){
  docker run \
    -it \
    --rm \
    --volume $PWD:/www:rw \
    --user www-data:www-data \
    --workdir /www \
    ve/php ${@}
}

ve-nginx-acme-run(){
  docker exec \
    -it \
    --user root:root \
    --workdir /www \
    ve-nginx /root/.acme.sh/acme.sh --cert-home /etc/nginx/ssl --nginx /etc/nginx/conf.d/default.conf ${@}
}

ve-docker-compose(){
  cd docker
  docker-compose ${@}
}

case "$1" in
  "start" | "up")
    ve-docker-compose up -d
    ;;
  "stop" | "down")
    ve-docker-compose down
    ;;
  "restart")
    ve-docker-compose restart
    ;;
  "docker-compose")
    ve-docker-compose ${@}
    ;;
  "php" | "composer")
    ve-php-run ${@}
    ;;
  "acme.sh")
    shift
    ve-nginx-acme-run ${@}
    ;;
  *)
    echo -e "\033[1;44;37mINFO\033[0m: WRONG COMMAND: ${1}"
    ;;
esac
